home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / net / PPP1_30.lha / PPP / src / PPPConfigAmiTCP30b.c < prev   
C/C++ Source or Header  |  1995-01-06  |  2KB  |  70 lines

  1. #include <exec/types.h>
  2. #include <exec/io.h>
  3. #include <proto/exec.h>
  4. #include <proto/dos.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8.  
  9. char *versionstring="$VER: PPPConfigAmiTCP30b 1.2 (06.01.95)";
  10. char *copyright="Copyright (C) 1994,1995 by Holger Kruse";
  11.  
  12. void main(int argc,char *argv[]) {
  13.     char localadr[64],remoteadr[64],envname[64];
  14.     int len,unit;
  15.     FILE *f;
  16.     if(argc==0)
  17.         exit(0);
  18.     if((argc<2)||(argc>3)) {
  19.         printf("Usage: %s unit [machinename]\n",argv[0]);
  20.         exit(0);
  21.     }
  22.     unit=atoi(argv[1]);
  23.     sprintf(envname,"ENV:ppp%dIPLocal",unit);
  24.     if(!(f=fopen(envname,"r"))) {
  25.         printf("Can't find %s !\n",envname);
  26.         exit(0);
  27.     }
  28.     len=fread(localadr,1,64,f);
  29.     localadr[len]=0;
  30.     fclose(f);
  31.     sprintf(envname,"ENV:ppp%dIPRemote",unit);
  32.     if(!(f=fopen(envname,"r"))) {
  33.         printf("Can't find %s !\n",envname);
  34.         exit(0);
  35.     }
  36.     len=fread(remoteadr,1,64,f);
  37.     remoteadr[len]=0;
  38.     fclose(f);
  39.     if(!(f=fopen("AmiTCP:db/netdb-myhost-tmp","w"))) {
  40.         printf("Can't open netdb-myhost-tmp !\n");
  41.         exit(0);
  42.     }
  43.     if(argc==3)
  44.         fprintf(f,"add HOST %s %s\n",localadr,argv[2]);
  45.     fclose(f);
  46.     if(argc==2) {
  47.         if(!(f=fopen("T:AmiTCP.rexx","w"))) {
  48.             printf("Can't open T:AmiTCP.rexx !\n");
  49.             exit(0);
  50.         }
  51.         fprintf(f,"/* temporary ARexx program to update AmiTCP's database */\n\n");
  52.         fprintf(f,"address AMITCP\n");
  53.         fclose(f);
  54.     }
  55.     if(!(f=fopen("T:AmiTCP.tmp","w"))) {
  56.         printf("Can't open T:AmiTCP.tmp !\n");
  57.         exit(0);
  58.     }
  59.     fprintf(f,"AmiTCP:bin/ifconfig lo0 localhost\n");
  60.     fprintf(f,"AmiTCP:bin/ifconfig ppp%d %s %s\n",unit,
  61.      localadr,remoteadr);
  62.     fprintf(f,"AmiTCP:bin/route add %s localhost\n",localadr);
  63.     fprintf(f,"AmiTCP:bin/route add default %s\n",remoteadr);
  64.     if(argc==2) {
  65.         fprintf(f,"echo \"*\"`AmiTCP:bin/resolve %s`*\"\" >>T:AmiTCP.rexx\n",localadr);
  66.         fprintf(f,"rx T:AmiTCP.rexx\n");
  67.     }
  68.     fclose(f);
  69. }
  70.